The Go Programming Language

Total Page:16

File Type:pdf, Size:1020Kb

The Go Programming Language ptg16091132 The Go Programming Language ptg16091132 This page intentionally left blank ptg16091132 The Go Programming Language Alan A. A. Donovan Google Inc. ptg16091132 Brian W. Kernighan Princeton University New York • Boston • Indianapolis • San Francisco Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trade- mark claim, the designations have been printed with initial capital letters or in all capitals. Th e authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, train- ing goals, marketing focus, or branding interests), please contact our corporate sales department at [email protected] or (800) 382-3419. For government sales inquiries, please contact [email protected]. For questions about sales outside the United States, please contact [email protected]. ptg16091132 Visit us on the Web: informit.com/aw Library of Congress Control Number: 2015950709 Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan All rights reserved. Printed in the United States of America. Th is publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, 200 Old Tappan Road, Old Tappan, New Jersey 07675, or you may fax your request to (201) 236-3290. Front cover: Millau Viaduct, Tarn valley, southern France. A paragon of simplicity in modern engi- neering design, the viaduct replaced a convoluted path from capital to coast with a direct route over the clouds. © Jean-Pierre Lescourret/Corbis. Back cover: the original Go gopher. © 2009 Renée French. Used under Creative Commons Attribu- tions 3.0 license. Typeset by the authors in Minion Pro, Lato, and Consolas, using Go, groff , ghostscript, and a host of other open-source Unix tools. Figures were created in Google Drawings. ISBN-13: 978-0-13-419044-0 ISBN-10: 0-13-419044-0 Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana. First printing, October 2015 The Go Programming Language © 2016 Alan A. A. Donovan & Brian W. Kernighan revision 3b600c, date 29 Sep 2015 Fo r Leil a an d Me g ptg16091132 This page intentionally left blank ptg16091132 The Go Programming Language © 2016 Alan A. A. Donovan & Brian W. Kernighan revision 3b600c, date 29 Sep 2015 Cont ents Pr eface xi TheOrigins ofGoxii TheGoPro jec t xiii Organizat ionofthe Bookxv ptg16091132 Wh ere toFindMoreInfor mat ionxvi Ac knowledgments xvii 1. Tutorial1 1.1. Hel lo, Wor ld1 1.2. Command-L ineArguments 4 1.3. FindingDup lic ateLines 8 1.4. Animated GIFs 13 1.5. FetchingaURL 15 1.6. FetchingURLs Con cur rently17 1.7. A We b Server 19 1.8. Loose End s 23 2. Pro gramStr ucture27 2.1. Names 27 2.2. Declarat ions 28 2.3. Var iables 30 2.4. Assig nments 36 2.5. Typ e Decl arat ions 39 2.6. Packages andFiles 41 2.7. Scope 45 vii The Go Programming Language © 2016 Alan A. A. Donovan & Brian W. Kernighan revision 3b600c, date 29 Sep 2015 viii CONTENTS 3. Basic Data Typ es51 3.1. Int egers 51 3.2. Float ing-Point Numbers 56 3.3. Complex Numbers 61 3.4. Boole ans63 3.5. Str ings64 3.6. Con stants75 4. Com positeTyp es81 4.1. Arrays 81 4.2. Slices 84 4.3. Maps 93 4.4. Str ucts99 4.5. JSON107 4.6. Text andHTMLTempl ates113 5. Func tions 119 5.1. FunctionDeclarat ions 119 5.2. Rec ursion121 5.3. MultipleRetur n Values 124 5.4. Erro rs127 5.5. FunctionValues 132 ptg16091132 5.6. Anony mou s Func tions 135 5.7. Var iadic Functions 142 5.8. Defer red FunctionCal ls143 5.9. Panic 148 5.10. Recov er151 6. Metho ds 155 6.1. Met hod Declarat ions 155 6.2. Met hodswit h aPoint erReceiver158 6.3. ComposingTyp es by Str uct Emb edding161 6.4. Met hod Values andExpressions 164 6.5. Example: Bit Vec tor Typ e 165 6.6. Encapsulat ion168 7. Interfaces171 7.1. Int erfaces as Contrac ts 171 7.2. Int erface Typ es 174 7.3. Int erface Satisfac tion175 7.4. ParsingFlags wit h flag.Value 179 7.5. Int erface Values 181 The Go Programming Language © 2016 Alan A. A. Donovan & Brian W. Kernighan revision 3b600c, date 29 Sep 2015 CONTENTSix 7.6. Sor tingwit h sort.Interface 186 7.7. The http.Handler Interface 191 7.8. The error Interface 196 7.9. Example: ExpressionEvaluator197 7.10. Typ e As ser tions 205 7.11. Discriminat ingError s with Typ e As ser tions 206 7.12. Quer yingBeh avior s with Int erface Typ e As ser tions 208 7.13. Typ e Sw itch es210 7.14. Example: Token-B ased XML Decoding213 7.15. A Fe w Wo rds ofAdv ice 216 8. Gor o utines and Channels 217 8.1. Goroutines217 8.2. Example: Con cur rentClo ckSer ver 219 8.3. Example: Con cur rentEch o Server 222 8.4. Channel s 225 8.5. Looping inParal lel234 8.6. Example: Con cur rentWeb Craw ler 239 8.7. Multiplexingwit h select 244 8.8. Example: Con cur rentDirec tor y Traversal247 8.9. Cancellat ion251 8.10. Example: ChatSer ver 253 ptg16091132 9. Concurrency withShared Vari ables257 9.1. Race Con dit ion s 257 9.2. Mut ual Exc lusion: sync.Mutex 262 9.3. Read/Write Mut exes: sync.RWMutex 266 9.4. Memor y Sy nchro nizat ion267 9.5. Lazy Initializat ion: sync.Once 268 9.6. TheRace Detec tor 271 9.7. Example: Con cur rentNon-Blo cking Cache 272 9.8. Goroutinesand Threads 280 10. Pack ages and the GoTool283 10.1. Int roduc tion283 10.2. Imp ort Pat hs284 10.3. ThePackageDeclarat ion285 10.4. Imp ort Declarat ions 285 10.5. Blank Imp orts286 10.6. Packages andNaming289 10.7. TheGoTool290 The Go Programming Language © 2016 Alan A. A. Donovan & Brian W. Kernighan revision 3b600c, date 29 Sep 2015 xCONTENTS 11. Testing 301 11.1. The go testTo ol302 11.2. Test Func tions 302 11.3. Cov erage318 11.4. Benchmark Func tions 321 11.5. Profiling323 11.6. Example Func tions 326 12. Reflecti on329 12.1. Why Reflec tion?329 12.2. reflect.Type and reflect.Value 330 12.3. Display,aRec ursiveValue Print er333 12.4. Example: Enco dingS-E xpressions 338 12.5. Setting Var iables wit h reflect.Value 341 12.6. Example: DecodingS-E xpressions 344 12.7. AccessingStr uct Field Tags 348 12.8. Displaying the Met hodsofaTyp e 351 12.9. A Wo rdofCaution 352 13. Low-L evel Pro gramming353 13.1. unsafe.Sizeof, Alignof,and Offsetof 354 13.2. unsafe.Pointer 356 ptg16091132 13.3. Example: DeepEquivalence 358 13.4. Cal lingCCodewit h cgo 361 13.5. Another WordofCaution 366 Index367 The Go Programming Language © 2016 Alan A. A. Donovan & Brian W. Kernighan revision 3b600c, date 29 Sep 2015 Pref ace ‘‘Go is anopensourc e prog rammi n g lang uagethatmak esiteasytobui ldsimpl e,rel iab le, an d efficientsof tware.’’ (Fro m theGoweb sit e at golang.org) Go was conceive d in Septemb er2007 byRob ert Gries emer,Rob Pike, and Ken Thomps on, all ptg16091132 at Google, and was announced inNov emb er2009. Thegoals ofthe langu ageand its accom- pany ing tools weretobeexpressive, efficientinbot h comp ilation and exe cut ion,and effec tive in writing reliableand robustprograms. Go bears a sur face simi lar ity toC and,likeC,isatoolfor prof essionalprogrammers, achie v- ingmaximum effe ctwit h minimum means.But it ismuchmorethananupdated versionof C. Itbor rowsand adaptsgood ide as from manyother langu ages, whi le avoidingfeaturesthat have led tocomplexity and unreliablecode. Its facilities for con cur rency are new and efficient, andits approach to dat a abstrac tionand obj e ct-oriente d prog rammingisunu sually flexible. It hasaut omat ic memory managementor garb age col lec tion. Go isesp eci ally wel l suit edfor bui ldinginf rastr ucturelikenet wor ked ser vers, andtools and systems for prog rammers, but it istruly a general-pur pos e language and find s us e in domains as divers e as graphics, mobileapp lic ations,and machinelearning. Ithas becom e popu lar as a repl acementfor unt ypedscr ipt ing langu ages because itbal ances expressivenesswit h safety : Go programstypic ally run fasterthanprogramswritt enindynamic langu ages andsuf fer far fe wer crashesdue tounexp ected typ e er ror s. Go isanopen-s ource pro jec t,sosourcecodefor itscompi ler,librar ies, andtools is fre ely avai l- able toany one.Contr ibution s to the pro jec t come fro m an active worldw ide community.Go runs onUnix-li kesystems—Linux, Fre eBSD, OpenBSD, Mac OS X—andonPlan9and Micros oft Windows.
Recommended publications
  • UNIX and Computer Science Spreading UNIX Around the World: by Ronda Hauben an Interview with John Lions
    Winter/Spring 1994 Celebrating 25 Years of UNIX Volume 6 No 1 "I believe all significant software movements start at the grassroots level. UNIX, after all, was not developed by the President of AT&T." Kouichi Kishida, UNIX Review, Feb., 1987 UNIX and Computer Science Spreading UNIX Around the World: by Ronda Hauben An Interview with John Lions [Editor's Note: This year, 1994, is the 25th anniversary of the [Editor's Note: Looking through some magazines in a local invention of UNIX in 1969 at Bell Labs. The following is university library, I came upon back issues of UNIX Review from a "Work In Progress" introduced at the USENIX from the mid 1980's. In these issues were articles by or inter- Summer 1993 Conference in Cincinnati, Ohio. This article is views with several of the pioneers who developed UNIX. As intended as a contribution to a discussion about the sig- part of my research for a paper about the history and devel- nificance of the UNIX breakthrough and the lessons to be opment of the early days of UNIX, I felt it would be helpful learned from it for making the next step forward.] to be able to ask some of these pioneers additional questions The Multics collaboration (1964-1968) had been created to based on the events and developments described in the UNIX "show that general-purpose, multiuser, timesharing systems Review Interviews. were viable." Based on the results of research gained at MIT Following is an interview conducted via E-mail with John using the MIT Compatible Time-Sharing System (CTSS), Lions, who wrote A Commentary on the UNIX Operating AT&T and GE agreed to work with MIT to build a "new System describing Version 6 UNIX to accompany the "UNIX hardware, a new operating system, a new file system, and a Operating System Source Code Level 6" for the students in new user interface." Though the project proceeded slowly his operating systems class at the University of New South and it took years to develop Multics, Doug Comer, a Profes- Wales in Australia.
    [Show full text]
  • B-Prolog User's Manual
    B-Prolog User's Manual (Version 8.1) Prolog, Agent, and Constraint Programming Neng-Fa Zhou Afany Software & CUNY & Kyutech Copyright c Afany Software, 1994-2014. Last updated February 23, 2014 Preface Welcome to B-Prolog, a versatile and efficient constraint logic programming (CLP) system. B-Prolog is being brought to you by Afany Software. The birth of CLP is a milestone in the history of programming languages. CLP combines two declarative programming paradigms: logic programming and constraint solving. The declarative nature has proven appealing in numerous ap- plications, including computer-aided design and verification, databases, software engineering, optimization, configuration, graphical user interfaces, and language processing. It greatly enhances the productivity of software development and soft- ware maintainability. In addition, because of the availability of efficient constraint- solving, memory management, and compilation techniques, CLP programs can be more efficient than their counterparts that are written in procedural languages. B-Prolog is a Prolog system with extensions for programming concurrency, constraints, and interactive graphics. The system is based on a significantly refined WAM [1], called TOAM Jr. [19] (a successor of TOAM [16]), which facilitates software emulation. In addition to a TOAM emulator with a garbage collector that is written in C, the system consists of a compiler and an interpreter that are written in Prolog, and a library of built-in predicates that are written in C and in Prolog. B-Prolog does not only accept standard-form Prolog programs, but also accepts matching clauses, in which the determinacy and input/output unifications are explicitly denoted. Matching clauses are compiled into more compact and faster code than standard-form clauses.
    [Show full text]
  • Cobol Vs Standards and Conventions
    Number: 11.10 COBOL VS STANDARDS AND CONVENTIONS July 2005 Number: 11.10 Effective: 07/01/05 TABLE OF CONTENTS 1 INTRODUCTION .................................................................................................................................................. 1 1.1 PURPOSE .................................................................................................................................................. 1 1.2 SCOPE ...................................................................................................................................................... 1 1.3 APPLICABILITY ........................................................................................................................................... 2 1.4 MAINFRAME COMPUTER PROCESSING ....................................................................................................... 2 1.5 MAINFRAME PRODUCTION JOB MANAGEMENT ............................................................................................ 2 1.6 COMMENTS AND SUGGESTIONS ................................................................................................................. 3 2 COBOL DESIGN STANDARDS .......................................................................................................................... 3 2.1 IDENTIFICATION DIVISION .................................................................................................................. 4 2.1.1 PROGRAM-ID ..........................................................................................................................
    [Show full text]
  • Introduction to Concurrent Programming
    Introduction to Concurrent Programming Rob Pike Computing Sciences Research Center Bell Labs Lucent Technologies [email protected] February 2, 2000 1 Overview The world runs in parallel, but our usual model of software does not. Programming languages are sequential. This mismatch makes it hard to write systems software that provides the interface between a computer (or user) and the world. Solutions: processes, threads, concurrency, semaphores, spin locks, message-passing. But how do we use these things? Real problem: need an approach to writing concurrent software that guides our design and implementation. We will present our model for designing concurrent software. It’s been used in several languages for over a decade, producing everything from symbolic algebra packages to window systems. This course is not about parallel algorithms or using multiprocessors to run programs faster. It is about using the power of processes and communication to design elegant, responsive, reliable systems. 2 History (Biased towards Systems) Dijkstra: guarded commands, 1976. Hoare: Communicating Sequential Processes (CSP), (paper) 1978. Run multiple communicating guarded command sets in parallel. Hoare: CSP Book, 1985. Addition of channels to the model, rather than directly talking to processes. Cardelli and Pike: Squeak, 1983. Application of CSP model to user interfaces. Pike: Concurrent Window System, (paper) 1988. Application of Squeak approach to systems software. Pike: Newsqueak, 1989. Interpreted language; used to write toy window system. Winterbottom: Alef, 1994. True compiled concurrent language, used to write production systems software. Mullender: Thread library, 1999. Retrofit to C for general usability. 3 Other models exist Our approach is not the only way.
    [Show full text]
  • UTF-8-Plan9-Paper
    Hello World or Kαληµε´ρα κο´σµε or Rob Pike Ken Thompson AT&T Bell Laboratories Murray Hill, New Jersey 07974 ABSTRACT Plan 9 from Bell Labs has recently been converted from ASCII to an ASCII- compatible variant of Unicode, a 16-bit character set. In this paper we explain the rea- sons for the change, describe the character set and representation we chose, and present the programming models and software changes that support the new text format. Although we stopped short of full internationalizationÐfor example, system error mes- sages are in Unixese, not JapaneseÐwe believe Plan 9 is the first system to treat the rep- resentation of all major languages on a uniform, equal footing throughout all its software. Introduction The world is multilingual but most computer systems are based on English and ASCII. The release of Plan 9 [Pike90], a new distributed operating system from Bell Laboratories, seemed a good occasion to correct this chauvinism. It is easier to make such deep changes when building new systems than by refit- ting old ones. The ANSI C standard [ANSIC] contains some guidance on the matter of ‘wide’ and ‘multi-byte’ characters but falls far short of solving the myriad associated problems. We could find no literature on how to convert a system to larger character sets, although some individual programs had been converted. This paper reports what we discovered as we explored the problem of representing multilingual text at all levels of an operating system, from the file system and kernel through the applications and up to the window sys- tem and display.
    [Show full text]
  • Tiny Tools Gerard J
    Tiny Tools Gerard J. Holzmann Jet Propulsion Laboratory, California Institute of Technology Many programmers like the convenience of integrated development environments (IDEs) when developing code. The best examples are Microsoft’s Visual Studio for Windows and Eclipse for Unix-like systems, which have both been around for many years. You get all the features you need to build and debug software, and lots of other things that you will probably never realize are also there. You can use all these features without having to know very much about what goes on behind the screen. And there’s the rub. If you’re like me, you want to know precisely what goes on behind the screen, and you want to be able to control every bit of it. The IDEs can sometimes feel as if they are taking over every last corner of your computer, leaving you wondering how much bigger your machine would have to be to make things run a little more smoothly. So what follows is for those of us who don’t use IDEs. It’s for the bare metal programmers, who prefer to write code using their own screen editor, and who do everything else with command-line tools. There are no real conveniences that you need to give up to work this way, but what you gain is a better understanding your development environment, and the control to change, extend, or improve it whenever you find better ways to do things. Bare Metal Programming Many developers who write embedded software work in precisely this way.
    [Show full text]
  • The Blit: a Multiplexed Graphics Terminal
    The Blit: A Multiplexed Graphics Terminal Rob Pike Bell Laboratories Murray Hill, New Jersey 07974 ABSTRACT The Blit is a programmable bitmap graphics terminal designed specifically to run with the Unix operating system. The software in the terminal provides an asynchronous multi-window environment, and thereby exploits the multiprogramming capabilities of the Unix system which have been largely under-utilized because of the restrictions of conventional terminals. This paper discusses the design motivation of the Blit, gives an overview of the user interface, mentions some of the novel uses of multiprogramming made possible by the Blit, and describes the implementation of the multiplexing facilities on the host and in the terminal. Because most of the functionality is provided by the ter- minal, the discussion focuses on the structure of the terminal’s software. Sometime in 1983 The Blit: A Multiplexed Graphics Terminal Rob Pike Bell Laboratories Murray Hill, New Jersey 07974 Introduction The Blit* is a graphics terminal characterized more by the software it runs than the hardware itself. The hardware is simple and inexpensive (Figure 1): 256K bytes of memory dual-ported between an 800×1024×1 bit display and a Motorola MC68000 microprocessor, with 24K of ROM, an RS-232 interface, a mouse and a keyboard. Unlike many graphics terminals, it has no special-purpose graphics hardware; instead, the microprocessor executes all graphical operations in software. The reasons for and conse- quences of this design are discussed elsewhere.5 The microprocessor may be loaded from the host with custom applications software, but the terminal is rarely used this way.
    [Show full text]
  • A Quick Reference to C Programming Language
    A Quick Reference to C Programming Language Structure of a C Program #include(stdio.h) /* include IO library */ #include... /* include other files */ #define.. /* define constants */ /* Declare global variables*/) (variable type)(variable list); /* Define program functions */ (type returned)(function name)(parameter list) (declaration of parameter types) { (declaration of local variables); (body of function code); } /* Define main function*/ main ((optional argc and argv arguments)) (optional declaration parameters) { (declaration of local variables); (body of main function code); } Comments Format: /*(body of comment) */ Example: /*This is a comment in C*/ Constant Declarations Format: #define(constant name)(constant value) Example: #define MAXIMUM 1000 Type Definitions Format: typedef(datatype)(symbolic name); Example: typedef int KILOGRAMS; Variables Declarations: Format: (variable type)(name 1)(name 2),...; Example: int firstnum, secondnum; char alpha; int firstarray[10]; int doublearray[2][5]; char firststring[1O]; Initializing: Format: (variable type)(name)=(value); Example: int firstnum=5; Assignments: Format: (name)=(value); Example: firstnum=5; Alpha='a'; Unions Declarations: Format: union(tag) {(type)(member name); (type)(member name); ... }(variable name); Example: union demotagname {int a; float b; }demovarname; Assignment: Format: (tag).(member name)=(value); demovarname.a=1; demovarname.b=4.6; Structures Declarations: Format: struct(tag) {(type)(variable); (type)(variable); ... }(variable list); Example: struct student {int
    [Show full text]
  • A Tutorial Introduction to the Language B
    A TUTORIAL INTRODUCTION TO THE LANGUAGE B B. W. Kernighan Bell Laboratories Murray Hill, New Jersey 1. Introduction B is a new computer language designed and implemented at Murray Hill. It runs and is actively supported and documented on the H6070 TSS system at Murray Hill. B is particularly suited for non-numeric computations, typified by system programming. These usually involve many complex logical decisions, computations on integers and fields of words, especially charac- ters and bit strings, and no floating point. B programs for such operations are substantially easier to write and understand than GMAP programs. The generated code is quite good. Implementation of simple TSS subsystems is an especially good use for B. B is reminiscent of BCPL [2] , for those who can remember. The original design and implementation are the work of K. L. Thompson and D. M. Ritchie; their original 6070 version has been substantially improved by S. C. Johnson, who also wrote the runtime library. This memo is a tutorial to make learning B as painless as possible. Most of the features of the language are mentioned in passing, but only the most important are stressed. Users who would like the full story should consult A User’s Reference to B on MH-TSS, by S. C. Johnson [1], which should be read for details any- way. We will assume that the user is familiar with the mysteries of TSS, such as creating files, text editing, and the like, and has programmed in some language before. Throughout, the symbolism (->n) implies that a topic will be expanded upon in section n of this manual.
    [Show full text]
  • Quick Tips and Tricks: Perl Regular Expressions in SAS® Pratap S
    Paper 4005-2019 Quick Tips and Tricks: Perl Regular Expressions in SAS® Pratap S. Kunwar, Jinson Erinjeri, Emmes Corporation. ABSTRACT Programming with text strings or patterns in SAS® can be complicated without the knowledge of Perl regular expressions. Just knowing the basics of regular expressions (PRX functions) will sharpen anyone's programming skills. Having attended a few SAS conferences lately, we have noticed that there are few presentations on this topic and many programmers tend to avoid learning and applying the regular expressions. Also, many of them are not aware of the capabilities of these functions in SAS. In this presentation, we present quick tips on these expressions with various applications which will enable anyone learn this topic with ease. INTRODUCTION SAS has numerous character (string) functions which are very useful in manipulating character fields. Every SAS programmer is generally familiar with basic character functions such as SUBSTR, SCAN, STRIP, INDEX, UPCASE, LOWCASE, CAT, ANY, NOT, COMPARE, COMPBL, COMPRESS, FIND, TRANSLATE, TRANWRD etc. Though these common functions are very handy for simple string manipulations, they are not built for complex pattern matching and search-and-replace operations. Regular expressions (RegEx) are both flexible and powerful and are widely used in popular programming languages such as Perl, Python, JavaScript, PHP, .NET and many more for pattern matching and translating character strings. Regular expressions skills can be easily ported to other languages like SQL., However, unlike SQL, RegEx itself is not a programming language, but simply defines a search pattern that describes text. Learning regular expressions starts with understanding of character classes and metacharacters.
    [Show full text]
  • Plan 9 from Bell Labs
    Plan 9 from Bell Labs “UNIX++ Anyone?” Anant Narayanan Malaviya National Institute of Technology FOSS.IN 2007 What is it? Advanced technology transferred via mind-control from aliens in outer space Humans are not expected to understand it (Due apologies to lisperati.com) Yeah Right • More realistically, a distributed operating system • Designed by the creators of C, UNIX, AWK, UTF-8, TROFF etc. etc. • Widely acknowledged as UNIX’s true successor • Distributed under terms of the Lucent Public License, which appears on the OSI’s list of approved licenses, also considered free software by the FSF What For? “Not only is UNIX dead, it’s starting to smell really bad.” -- Rob Pike (circa 1991) • UNIX was a fantastic idea... • ...in it’s time - 1970’s • Designed primarily as a “time-sharing” system, before the PC era A closer look at Unix TODAY It Works! But that doesn’t mean we don’t develop superior alternates GNU/Linux • GNU’s not UNIX, but it is! • Linux was inspired by Minix, which was in turn inspired by UNIX • GNU/Linux (mostly) conforms to ANSI and POSIX requirements • GNU/Linux, on the desktop, is playing “catch-up” with Windows or Mac OS X, offering little in terms of technological innovation Ok, and... • Most of the “modern ideas” we use today were “bolted” on an ancient underlying system • Don’t believe me? A “modern” UNIX Terminal Where did it go wrong? • Early UNIX, “everything is a file” • Brilliant! • Only until people started adding “features” to the system... Why you shouldn’t be working with GNU/Linux • The Socket API • POSIX • X11 • The Bindings “rat-race” • 300 system calls and counting..
    [Show full text]
  • Programming, While at Once Focussing on Fast Compilation and Code Execution
    Some Trucs and Machins about Google Go Narbel The Cremi’s Saturdays, Saison I University of Bordeaux 1 April 2010 (v.1.01) 1 / 41 A “New” Language in a Computerizationed World I A magnificent quartet...: I Microsoft: Windows, Internet Explorer (Gazelle?), Microsoft Office, Windows Mobile, C#/F#. I Sun: Solaris, HotJava, StarOffice, SavaJe, Java. I Apple: MacOS, Safari, iWork, iPhoneOS, Objective-C. I Google: ChromeOS, Chrome, Google Docs, Android, Go. I Go: the last brick (born in November 2009). 2 / 41 Objective-C and Go: a new kind of progression...(from www.tiobe.com, April 2010) 3 / 41 Creating New Languages and Tactics... I “Securing” languages for oneself, a modern tactics? e.g.: I Java ← C# (Microsoft). I OCaml ← F# (Microsoft). I C ← Go ? (Google). I In the Go team, some “C/Unix-stars”: I Ken Thompson (Multics, Unix, B, Plan 9, ed, UTF-8, etc. – Turing Award). I Rob Pike (Plan 9, Inferno, Limbo, UTF-8, etc.) 4 / 41 One of the Underlying Purposes of Go...!? I Many recent successful languages are dynamic-oriented, i.e. Python, Ruby, etc. or extensions/avatars of Java, like Clojure and Groovy. I In the official Go tutorial: “It feels like a dynamic language but has the speed and safety of a static language.” I Even if there exist dynamic languages with very efficient compilers (cf. CLOS), Go takes a step out of the current dynamic-oriented trend, and proposes more type-safe programming, while at once focussing on fast compilation and code execution... (i.e. towards high-performance web programming?). 5 / 41 Apart´e:Compiled, Interpreted, Tomato-Souped..
    [Show full text]